<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>调代看课详情-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart style="background-color: #fff;">
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-blue"> 
	  		<div class="weui-header-left">
	  		 <a href="<%=basePath %>/ls/teacher/change/course" href="javascript:;" class="icon icon-109 f-white">返回</a > 
	  		</div>
	    	<h1 class="weui-header-title">调代看课详情</h1>
	    </div>
		<div class="weui_tab_bd" style="padding-bottom: 95px;">
			<div class="weui_panel_bd">
                <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg">
                    <div class="weui_media_hd">
                        <img style="border-radius: 100%;" class="weui_media_appmsg_thumb" src="${config.imgUrl }${detail.headImgUrl}" alt="">
                    </div>
                    <div class="weui_media_bd">
                        <h4 class="weui_media_title">${detail.applyTeacherName }</h4>
                        <p class="weui_media_desc f-orange">${detail.applyStatusText }</p>
                    </div>
                </a>
			</div>
			
			<div class="weui_cells mt0">
				<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span class="f-graybc">事由：</span>${detail.reason }
					</div>
				</div>
			</div>
			<div class="weui_cells mt0">
				<div class="weui_media_fd  tright weui_btn_area">
               		<div class="zhangtai" style="top: 2em; z-index: 500;">
               			<span class="f-blue">
               				<c:choose>
               					<c:when test="${detail.status == '001' || detail.status == '004' }">
               						<img class='img-max' src='<%=basePath %>/images/daish.png'>
               					</c:when>
               					<c:when test="${detail.status == '002' || detail.status == '000' }">
               						<img class='img-max' src='<%=basePath %>/images/shenpitongguo.png'>
               					</c:when>
               					<c:when test="${detail.status == '003' || detail.status == '005' || detail.status == '006'}">
               						<img class='img-max' src='<%=basePath %>/images/shenpibohui.png'>
               					</c:when>
               				</c:choose>
               			</span>
               		</div>
                </div>
				<div class="weui_cell xtbg-add-list-title">
					<div class="weui_cell_bd weui_cell_primary">
						<p class="f16 tdk-title">调代看课${status.index + 1 }</p>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span class="f-graybc">时间节次：</span> <fmt:formatDate type="date" value="${detail.courseDate }" /> ${detail.lesson }
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span class="f-graybc">调代看课类型：</span> ${detail.optionTypeText }
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span class="f-graybc">班级：</span>${detail.gradeName }（${detail.clazz }）班
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_bd weui_cell_primary">
						<span class="f-graybc">课程：</span> ${detail.subjectName }
					</div>
				</div>
				<div class="weui_cell">
					<c:choose>
						<c:when test="${detail.hasExchangeTeacher == 0 && empty detail.exchangeTeacherId && isAuditer > 0}">
							<div class="weui_cell_hd">
								<label class="weui_label"><span class="tdk-key">调代看老师</span></label>
							</div>
							<div class="weui_cell_bd weui_cell_primary weui_cell_ft">
			                	<div class="searchbar_wrap">
			                		<div class="weui_search_bar">
			                			<form class="weui_search_outer">
			                				<div class="weui_search_inner">
			                					<i class="weui_icon_search"></i>
			                					<input type="search" class="weui_search_input" placeholder="请输入教师姓名">
			                					<i class="weui_icon_clear"></i>
			                				</div>
			                			</form>
			                		</div>
			                	</div>
								<div id="search-content" style="height: 100%; z-index: 10; transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);">
							       <div class="sb-content" style="position:inherit;overflow:scroll;"></div>
							    </div>
							    <input type="hidden" name="exchangeTeacherId" class="tdk-value">
							    <input type="hidden" name="exchangeTeacherName">
							    <input type="hidden" name="id" value="${detail.id }"/>
			                </div>
						</c:when>
						<c:otherwise>
							<div class="weui_cell_bd weui_cell_primary">
								<span class="f-graybc">调代看教师：</span>
								<c:choose>
									<c:when test="${detail.hasExchangeTeacher == 0 && empty detail.exchangeTeacherId}">
										<span class="f-red">(需由教务处指派)</span>
									</c:when>
									<c:otherwise>
										${detail.exchangeTeacherName }
										<c:if test="${detail.hasExchangeTeacher == 0 }">
											<span class="f-red">(由教务处指派)</span>
										</c:if>
									</c:otherwise>
								</c:choose>
							</div>
						</c:otherwise>
					</c:choose>
				</div>
				<c:if test="${detail.optionType == 1 }">
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<span class="f-graybc">调课时间节次：</span><fmt:formatDate type="date" value="${detail.exchangeCourseDate }" /> ${detail.exchangeLesson }
						</div>
					</div>
					<div class="weui_cell">
						<div class="weui_cell_bd weui_cell_primary">
							<span class="f-graybc">调课课程：</span>${detail.exchangeSubjectName }
						</div>
					</div>
				</c:if>
			</div>
		</div>
	</div>
	<c:choose>
		<c:when test="${detail.status == '001' }">
			<section class="weui-menu">
		        <div class="weui-menu-inner" id="rejectSubmit">
		            <span>驳回</span>
		        </div>
		        <div class="weui-menu-inner" id="agreeSubmit">
		            <span>同意</span>
		        </div>
		    </section>
		    <!--弹窗-->				
		<div class="weui_mask ueureiu weui_mask_visible" style="display: none;z-index:600">
		</div>
		<!--End弹窗-->
		<div class="weui_dialog weui_dialog_visible" style="transform-origin: 0px 0px 0px; opacity: 1; transform: scale(1, 1);display:none;z-index:700;">
			<div class="weui_dialog_hd">
				<strong class="weui_dialog_title">请输入驳回原因</strong>
			</div>
			<div class="weui_dialog_bd">
				<textarea class="weui-prompt-input" style="height: 80px;width: 95%;" rows="10" id="rejectText"></textarea>
			</div>
			<div class="weui_dialog_ft">
				<a href="javascript:;" id="rejectCancel" class="weui_btn_dialog default">取消</a>
				<a href="javascript:;" id="rejectSure" class="weui_btn_dialog primary">确定</a>
			</div>
		</div>
		<script>
			$(function() {
		      	$("#agreeSubmit").click(function() {
		      		$.confirm("您确定审批通过吗?","", function() {
		      			agreeSubmit();
		            }, function() {
		                //取消操作
		            });
		      	})
		      	$("#rejectSubmit").click(function() {
	      			$(".weui_mask").addClass("weui_mask_visible").show();
	      			$(".weui_dialog").addClass("weui_dialog_visible").show();
	      			$("#rejectCancel").click(function(){
	      				$("#rejectText").val(null);
	      				$(".weui_mask").hide();
	      				$(".weui_dialog").hide();
	      			});
	      			$("#rejectSure").click(function(){
	      				var text = $("#rejectText").val();
	      				if(text.trim().length > 0) {
	      		      		var params = {
	      		  				id: "${detail.id}",
	      		  				applyId: "${detail.applyId}",
	      		      			rejectReason: text
	      		      		}
	      		      		replySubmit(params);
		      		      	$(".weui_mask").hide();
		      				$(".weui_dialog").hide();
		      				$("#rejectText").val(null);
	      		      	}
	      			});
		      	})
			});
			function replySubmit(params) {
				$.ajax({
		          	url : basePath + "/ls/teacher/change/course/teacher/audit/reject",
		  	 		type : "post",
		  	 		dataType : "json",
		  	 		data : params,
		            success: function(data){
		            	if(data.code == '000') {
		            		$.toast("提交成功！");
		            		setTimeout(function() {
		            			window.location.reload();
		            		}, 1000);
		            		return;
		            	}
		            	$.toptips(data.msg);
		            },
		            error: function(xhr, type){
		            	$.toptips("系统异常");
		            }
		         });
			}
			function agreeSubmit() {
				var obj = {
					id: "${detail.id}",
					applyId: "${detail.applyId}",
				};
				$.ajax({
					url: basePath + '/ls/teacher/change/course/teacher/audit/success',
					type: 'post',
					dataType: 'json',
					data : obj,
					success: function(data) {
						if(data.code == '000') {
							$.toast("提交成功");
							setTimeout(function() {
								window.location.reload();
		            		}, 1000);
						}else {
							$.toptips(data.msg);
						}
					},
		            error: function(xhr, type){
		            	$.toptips("系统异常");
		            }
				});
			}
		</script>
		</c:when>
		<c:otherwise>
			<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
		</c:otherwise>
	</c:choose>
</body>
<script>
	
	
</script>
</html>